package com.wzh.store.controller;

import com.wzh.store.entity.Product;
import com.wzh.store.service.IProductService;
import com.wzh.store.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author wzh
 * @create 2022/4/29 15:43
 * @Description：
 */
@RestController
@RequestMapping("products")
public class ProductController extends BaseController{
    @Autowired
    public IProductService iProductService;
    @RequestMapping("host_list")
    public JsonResult<List<Product>> showHostProducts(){
        List<Product> list = iProductService.findHostProduct();
        return new JsonResult<>(ok,list);
    }

    @RequestMapping("{id}/details")
    public JsonResult<Product> getProById(@PathVariable("id") Integer id){
        Product pro = iProductService.findById(id);
        return new JsonResult<>(ok,pro);
    }

}
